<?php
/**
 * 合成列表
 */
header('Content-Type:text/html;charset=utf8');

require './../wog_act_config.php';
require './../class/wog_fight_event.php';
$df = require './../views/data-df.php';
//var $topr_vip = 1;//掉宝率参数
//########## get_item begin   ##########
function randGetItemId($user_id, $m_id, $m_topr, $p_st, $p_bag)
{
    $temp_fight_string = "";
    $mercenary_topr = 1;
    $mercenary_get = "";
    global $wog_array, $df;
    // 怪物可掉落物品列表string
    $temp_m_id = explode(",", $m_id);
    // 掉落概率
    $temp_m_topr = explode(",", $m_topr);
    // 总概率
    $total_topr = array_sum($temp_m_topr);
    $temp_get_item = [];
    $top_get = 0;
    $topr_vip = $wog_array['vip_get_item_topr'][$p_st];//掉宝率参数

    // switch
    echo '<p><strong style="color: #ff4409">掉落物品</strong>：刷新时可模拟每一次战斗掉落</p>';
    echo '<h2>加成等级：<strong style="color: #ff4409;">Lv ' . $p_st . '</strong> <small style="margin-left: 20px;">加成概率：<strong style="color: #ff4409">' . $topr_vip . '</strong></small></h2>';
    echo '<p ><strong style="color: #ff0000;">[1]</strong> <span style="color: #ff4409">当掉落等级的加成值=0时，物品规定掉落概率为1%。</span></p>';
    echo '<p><em>只有加成等级=0且无加成，才会修正为基础概率100</em></p>';
    echo '<h1>举例：</h1>';
    echo '<table style="text-align: center;width: 100%;"  border="1" cellspacing="0" cellpadding="5"><tr>';
    echo '<th class="font-size-12 text-white">战斗奖励物品</th>';
    echo '<th class="font-size-12 text-white">默认掉落概率值<br>(1-1000)</th>';
    echo '<th class="font-size-12 text-white">默认掉落概率<br>（0-100%）</th>';
    echo '<th class="font-size-12 text-white">加成修正后<br>掉落值<span style="color: #f00;">[1]</span></th>';
    echo '<th class="font-size-12 text-white">修正掉落概率<br>(0%-100%)</th>';
//    echo '<th class="font-size-12 text-white">修正掉落范围<br>（1-该值）</th>';
    echo '<th width="100" style="border:0;"></th>';
//    echo '<th class="text-white">加成等级</th>';
    echo '<th class="font-size-12 text-white">加成比例</th>';
    echo '<th class="font-size-12 text-white">最终掉落范围<br>（1-该值）</th>';
    echo '<th class="font-size-12 text-white">加成后<br>掉落概率</th>';
    echo '<th class="font-size-12 text-white">掉落物品</th>';
    echo '</tr>';
    for ($i = 0; $i < count($temp_m_topr); $i++) {
        if ($mercenary_topr > 1) {
            $top_get = ((($temp_m_topr[$i] * (100 - $mercenary_topr)) / 100) + $temp_m_topr[$i]);
        } else {
            $top_get = $temp_m_topr[$i];
        }
        // 默认掉落最大随机
        $rand_max = 1;
// 基础概率，1/掉落
        $base_topr_min = 1;
        $base_topr = $base_topr_min / $top_get;
        $final_topr = $topr_vip + $base_topr;
        if ($topr_vip == 0) {
            $top_get = 100;
        } else if ($topr_vip > 0 && $topr_vip < 1) {
            $rand_max = $top_get * $final_topr;
        } else if ($topr_vip == 1) {
            $rand_max = $top_get;
        }
        $ran_top_get = rand(1, $top_get);
        if ($ran_top_get <= $rand_max && $temp_m_id[$i]) {
            array_push($temp_get_item, $temp_m_id[$i]);
        }
        echo '<tr>';
        echo '<td>' . $df[$temp_m_id[$i]] . '</td>';
        echo '<td>' . $temp_m_topr[$i] . '</td>';
        echo '<td>' . round($base_topr_min / $temp_m_topr[$i] * 100, 2) . '%</td>';
        echo '<td>' . $top_get . '</td>';
        echo '<td>' . round($base_topr_min / $top_get * 100, 2) . '%</td>';
//        echo '<td>' . $rand_max . '</td>';
        echo '<td style="border:0;"></td>';
//        echo '<td  class="text-prompt font-weight-bold">' . $p_st . '</td>';
        echo '<td  class="text-prompt font-weight-bold">' . round($topr_vip * 100, 2) . '%</td>';
        echo '<td>' . $rand_max . '</td>';
        echo '<td  class="text-prompt font-weight-bold">' . round($final_topr * 100, 2) . '%</td>';
        echo '<td>' . $df[$temp_get_item[$i]]. '</td>';
        echo '</tr>';
    }

    echo '</table>';
}

$monsters = require './../views/data-monster.php';
$id = $_GET['id'];

$curr_monster = null;
if (isset($id) && !empty($id)) {
    $curr_monster = $monsters['json'][$id];
} else {
    $curr_monster =$monsters['array'];
}
$dids = $curr_monster['d_id'];
$topr = $curr_monster['m_topr'];

?>
<?php include './../layout/head.inc.php' ?>
<style>body {
        background-color: #d6bb9f;
        font-size: 16px;


    }</style>
<div style="padding-left: 170px;margin: 0 auto;" class="box-border-gradient bg-primary text-gold pos-r full-height-min">
    <div class="pos-f box-border-gold-bg full-screen-height overflow-y-auto top-left-0 bg-primary" style="width:150px;">
        <?php foreach ($monsters['array'] as $val) {
            echo "<a class='d-block font-size-12 text-gold text-overflow p-5' href=\"?id={$val['m_id']}\">[{$val['m_place']}] {$val['m_name']}</a>";
        } ?>
    </div>
    <h1 style="text-align:center;">战斗物品掉落模拟器</h1>
    <hr>
    <?php
    foreach ($wog_array['vip_get_item_topr'] as $k => $v) {
        randGetItemId(2792, $dids, $topr, $k, 0);
    }

    ?>
</div>

<?php include './../layout/foot.inc.php' ?>

